package com.example.tellwin.view;

import android.Manifest;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;

import com.example.tellwin.MainApplication;
import com.example.tellwin.R;
import com.example.tellwin.common.Common;
import com.example.tellwin.utils.ToastUtil;

import java.io.File;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

import static com.example.tellwin.common.Common.PhotoAlbumRequestCode;
import static com.example.tellwin.common.Common.TakePhotoRequestCode;

/**
 * @author : LinZePeng
 * @date : 2020/11/9
 * @Describe ：
 **/
public class AnswerTypeDialog extends Dialog {

    Activity activity;

    @BindView(R.id.voice_answer_btn)
    Button voiceAnswerBtn;
    @BindView(R.id.video_answer_btn)
    Button videoAnswerBtn;
    @BindView(R.id.board_answer_btn)
    Button boardAnswerBtn;

    AnswerTypeItemClick answerTypeItemClick;

    public AnswerTypeDialog(@NonNull Activity activity , AnswerTypeItemClick answerTypeItemClick) {
        super(activity);
        this.activity = activity;
        this.answerTypeItemClick = answerTypeItemClick;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_answer_type);
        ButterKnife.bind(this);
        Window window = this.getWindow();
        //设置位置在屏幕底部
        window.setGravity(Gravity.BOTTOM);
        //设置弹入弹出动画
        window.setWindowAnimations(R.style.BottomDialog_Animation);
        //设置为全屏dialog
        WindowManager.LayoutParams params = window.getAttributes();
        params.width = WindowManager.LayoutParams.MATCH_PARENT;
        params.height = WindowManager.LayoutParams.WRAP_CONTENT;
        window.setAttributes(params);

    }

    @OnClick({R.id.voice_answer_btn, R.id.video_answer_btn, R.id.board_answer_btn})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.voice_answer_btn:
                answerTypeItemClick.onClick(1);
                dismiss();
                break;
            case R.id.video_answer_btn:
                answerTypeItemClick.onClick(2);
                dismiss();
                break;
            case R.id.board_answer_btn:
                answerTypeItemClick.onClick(3);
                dismiss();
                break;
        }
    }

    public interface AnswerTypeItemClick{
        void onClick(int type);
    }
}
